$input_tped = $ARGV[0];
$input_gprobs = $ARGV[1];
$output_gprobs = $ARGV[2];
$input_ind = $ARGV[3];
$output_ind = $ARGV[4];
chomp($input_tped);
chomp($input_gprobs);
chomp($output_gprobs);
chomp($input_ind);
chomp($output_ind);
open(BUFF,$input_tped) or die "no file perl_final_4sort.pl $input_tped\n";
open(BUFF1,$input_gprobs) or die "no file perl_final_4sort.pl $input_gprobs\n";
open(BUFF2,$input_ind) or die "no file perl_final_4sort.pl $input_ind\n";
open(WRBUFF1,">$output_gprobs") or die "not able write perl_final_4sort.pl $output_gprobs\n";
open(WRBUFF2,">$output_ind") or die "not able write perl_final_4sort.pl$output_ind\n";
#reading tpead and storing map info in the hash
while(<BUFF>)
{
	chomp($_);
	@array = split(" ",$_);
	$hash{$array[1]}=$array[0]." ".$array[1]." ".$array[2]." ".$array[3];
}
#for dosage
while(<BUFF1>)
{
        chomp($_);
	@array = split(" ",$_);
	if(exists($hash{$array[0]}))
	{
		print WRBUFF1 $hash{$array[0]}." ".$_."\n";
	}
	else
	{
		die "no map info for snp in dosage perl_final_4sort.pl \n";
	}
}
#for indicator
while(<BUFF2>)
{
        chomp($_);
        @array = split(" ",$_);
        if(exists($hash{$array[0]}))
        {
                print WRBUFF2 $hash{$array[0]}." ".$_."\n";
        }
        else
        {
                die "no map info for snp in ind perl_final_4sort.pl \n";
        }
}
close(BUFF);
close(BUFF1);
close(BUFF2);
close(WRBUFF1);
close(WRBUFF2);
